package utils

import (
	"strconv"
	"time"
)

func GetTimestamp() int64 {
	return time.Now().Unix()
}

func GetTimestampMS() float64 {
	return float64(time.Now().UnixNano()) / 1000000
}

func GetTimestampUS() float64 {
	return float64(time.Now().UnixNano()) / 1000
}

func GetTimestampNS() int64 {
	return time.Now().UnixNano()
}

func GetTimestampStr() string {
	return strconv.FormatInt(time.Now().Unix(), 10)
}

func GetCurrentTimeString() string {
	return time.Now().Format("2006-01-02 15:04:05")
}

func ParseStringTime(strTime string) time.Time {
	target, err := time.Parse("2006-01-02 15:04:05", strTime)
	if err != nil {
		panic(err)
	} else {
		return target
	}
}

func ParseStringTimeToTimestamp(strTime string) int64 {
	target, err := time.Parse("2006-01-02 15:04:05", strTime)
	if err != nil {
		panic(err)
	} else {
		return target.Unix()
	}
}

func ParseStringTimeToTimestampString(strTime string) string {
	target, err := time.Parse("2006-01-02 15:04:05", strTime)
	if err != nil {
		panic(err)
	} else {
		return strconv.FormatInt(target.Unix(), 10)
	}
}
